package jxc.data.hibernate.dao;

import java.util.List;

import org.hibernate.Query;

import jxc.data.hibernate.pojo.Goods;

public class GoodsDAO extends HibernateBaseDAO<Goods> {
	@SuppressWarnings("unchecked")
	public List<Goods> getLikeName(String name){
		String hql="from Goods where goodsname like :name";
		Query query=session.createQuery(hql);
		query.setString("name", '%'+name+'%');
		return query.list();
	}
	
	public Goods getById(String id){
		String hql="from Goods where id=:id";
		Query query=session.createQuery(hql);
		query.setString("id", id);
		return (Goods) query.uniqueResult();
	}
	
	@SuppressWarnings("unchecked")
	public List<Goods> getAll(){
		String hql="from Goods";
		Query query=session.createQuery(hql);
		return query.list();
	}
	
}
